/// @tags: Matrix
#include <cstdio>
#include <iomanip>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

typedef long long LL;

constexpr int maxm = 3, p = 998244353, base = 128, maxexp = 15;

struct Vector;
struct Matrix;

struct Vector {
  int a[maxm];

  inline Vector() : a{0, 0, 0} {}
  inline Vector(int x, int y, int z) : a{x, y, z} {}

  inline int &operator[](int index) { return a[index]; }
  inline const int &operator[](int index) const { return a[index]; }

  Vector operator*(const Matrix &) const;
};

struct Matrix {
  Vector a[maxm];

  inline Matrix(int x = 0) {
    for (rint i = 0; i < maxm; ++i) {
      for (rint j = 0; j < maxm; ++j) a[i][j] = i == j ? x : 0;
    }
  }

  inline Vector &operator[](int index) { return a[index]; }
  inline const Vector &operator[](int index) const { return a[index]; }

  inline Matrix operator*(const Matrix &rhs) const {
    Matrix res;
    for (rint i = 0; i < maxm; ++i) res[i] = a[i] * rhs;
    return res;
  }
} T[maxexp][base];

inline Vector Vector::operator*(const Matrix &rhs) const {
  Vector res;
  for (rint i = 0; i < maxm; ++i) {
    for (rint j = 0; j < maxm; ++j) res[i] = (res[i] + (LL)a[j] * rhs[j][i]) % p;
  }
  return res;
}

inline void prework() {
  Matrix &trans = T[0][1];
  trans[0] = {0, 1, 0};
  trans[1] = {2, 2, 0};
  trans[2] = {1, 2, 1};
  for (rint i = 2; i < base; ++i) T[0][i] = T[0][i - 1] * trans;
  for (rint i = 1; i < maxexp; ++i) {
    T[i][1] = T[i - 1][base - 1] * T[i - 1][1];
    for (rint j = 2; j < base; ++j) {
      T[i][j] = T[i][j - 1] * T[i][1];
    }
  }
}

inline Vector query(LL n) {
  Vector res = {1, 2, 1};
  rint exp = 0;
  while (n) {
    if (n % base) res = res * T[exp][n % base];
    n /= base;
    exp++;
  }
  return res;
}

inline int main() {
  int T, a = 0, b = 0;
  cin >> T;
  prework();
  while (T--) {
    LL n;
    cin >> n;
    Vector res = query(n - 1);
    a ^= res[0], b ^= res[1];
  }
  cout << std::setw(5) << a << ' ' << std::setw(5) << b;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("riemannian.in", "r", stdin);
  freopen("riemannian.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
